import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

import Login from "@/views/login/index.vue";
import Register from "@/views/register/index.vue";

export default new Router({
  mode: "history",
  routes: [
    {
      path: "/",
      redirect: "/login",
    },
    {
      path: "/login", // 登入
      name: "login",
      component: Login,
    },
    {
      path: "/register", // 注册
      name: "register",
      component: Register,
    },
    {
      path: "/detail",
      name: "detail",
      component: () => import("@/views/detail/index.vue"),
    },
    {
      path: "/home",
      name: "home",
      component: () => import("@/views/home/index.vue"),
      children: [
        // 公共
        {
          path: "index", // 商品展示首页
          name: "index",
          component: () => import("@/views/admin/products/index.vue"),
        },
        // 管理员
        {
          path: "goods", // 商品管理
          name: "goods",
          component: () => import("@/views/admin/goods/index.vue"),
        },
        {
          path: "user", // 用户管理
          name: "user",
          component: () => import("@/views/admin/user/index.vue"),
        },
        // 学生
        {
          path: "shoppingcart", // 购物车
          name: "shoppingcart",
          component: () => import("@/views/student/shoppingcart/index.vue"),
        },
        {
          path: "orders", // 交易订单
          name: "orders",
          component: () => import("@/views/student/orders/index.vue"),
        },
        {
          path: "buyOrders", // 个人订单
          name: "buyOrders",
          component: () => import("@/views/student/buyOrders/index.vue"),
        },
        {
          path: "personal", 
          name: "personal",
          component: () => import("@/views/student/personal/index.vue"),
        },
        // 评论管理
        {
          path: "comment",
          name: "comment",
          component: () => import("@/views/student/comment/index.vue"),
        },
      ],
    },
  ],
});
